<div class="row">
    <?php echo CHtml::Label('searchText','search'); ?>
    <?php echo CHtml::TextField('search'); ?>
    <?php echo CHtml::link('Search','#',array('grid_id'=>'warehousecargo_grid','id'=>'search')); ?>
</div>
<?php
	$this->widget('application.widgets.RiotingNerds.RiotingGrid',array(
		'id'=>"warehousecargo_grid",
		'dataProvider'=>$model->in_warehouse(),
		'columns'=>array(
			'in_date:date:Date',
			'marking:text:Marking',
			'consignee.cname:text:Consignee',
			array(
				'class'=>'CLinkColumn',
				'label'=>'Add',
				'urlExpression'=>'CHtml::normalizeUrl(array("packing_list/addcargo","cargo_id"=>$data->id,"id"=>'.$packing_id.'))',
				'linkHtmlOptions'=>array('id'=>'add_cargo'),
			),
		),
	));   
?>
<?php
$cs = Yii::app()->getClientScript();
$script =<<<EOD
$('input#searchText').keypress(function(event){
	if(event.keyCode == '13'){
		$.fn.yiiGridView.update('warehousecargo_grid',{data:{searchText:$(this).val()}});
	}
});
$('a#search').click(function(){
	var searchInput = $(this).prev('input#search');
	$.fn.yiiGridView.update($(this).attr('grid_id'),{data:{searchText:$(searchInput).val()}});
	return false;
});
EOD;
$cs->registerScript('warehouseCargo#grid',$script);
?>